package model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class ContractRule extends Rule {
	
	private static HashMap<Long, Long> contractRuleMap = new HashMap<Long,Long>();
	
	static{
		contractRuleMap.put(new Long(1000), new Long(1));
		contractRuleMap.put(new Long(5000), new Long(2));
		contractRuleMap.put(new Long(10000), new Long(3));
		contractRuleMap.put(new Long(20000), new Long(4));
		contractRuleMap.put(new Long(30000), new Long(5));
		contractRuleMap.put(new Long(100000), new Long(6));
		contractRuleMap.put(new Long(500000), new Long(7));
	}
	
	public long getMaxLevel(Contract c){
		double cost = c.getCost();
		long tempLevel = 0;
		Collection<Long> keyValues = contractRuleMap.keySet();
		List<Long> lstKeys = new ArrayList<Long>();
		lstKeys.addAll(keyValues);
		Collections.sort(lstKeys);
		
		for(Long l :lstKeys ){
			tempLevel = contractRuleMap.get(l);
			if(cost < l){
				
				return tempLevel;
			}
		}
		return tempLevel+1;	 
		
	}
	
}
